export default function () {
    return {
        formData: null,
        options: {
            // inline:true,
            labelWidth: "80px",
            // style: { width: "700px" },
            // size: "small",
        },
        items: [
            {
                formItem: { label: "角色名", required: true },
                itemRender: {
                    el: "el-input",
                    placeholder: "角色名",
                    value: "roleName",
                    style: { width: '260px' }
                },
            },
            {
                formItem: { label: "权限" },
                itemRender: {
                    el: "ChfSesectTree",
                    value: "permissions",
                    options: {
                        placeholder: "权限",
                        style: { width: '260px' },
                        data: [],
                        setLabel (item) {
                            if (item.isButton) {
                                return item.title
                            }
                            return item.meta.title
                        },
                        ['node-key']: "id",
                        ['filter-node-method'] (value, data) {
                            if (!value) return true;
                            return data.meta.title?.indexOf(value) !== -1;
                        },
                        ['render-content']: (h, { node, data, store }) => {
                            return (
                                <span class="custom-tree-node">
                                    {
                                        node.level === 1 ? <i class={data.meta.icon}></i> : ''
                                    }
                                    {
                                        data.isButton === true ? <span>{data.title}</span> : <span>{data.meta.title}</span>
                                    }
                                </span>
                            )
                        },
                    },
                    query: async (options) => {
                        const { result } = await this.$api.getMenuList();
                        options.data = result;
                        // this.value = [
                        //     1, 2, 3
                        // ]
                    }

                },
            },

            {
                formItem: { label: "备注", required: true },
                itemRender: {
                    el: "el-input",
                    placeholder: "备注",
                    value: "remark",
                    type: "textarea",
                    style: { width: '260px' }
                },
            },

        ],
    }
}